#include "stm32f0xx_hal.h"
#include "mo_button.h"
#include "user_app.h"

/*@TODO: You have to finish below codes which depend on your software requirement*/

typedef struct usr_app_tsk_{
    uint32_t sys_tick;
    uint8_t btn_polling_tick;
}UserAppTsk_t;

UserAppTsk_t usr_tsk;

void usr_app_main_loop(void) {
    if (usr_tsk.sys_tick != HAL_GetTick()) {
        usr_tsk.sys_tick = HAL_GetTick();
        mo_button_loop(1/*Invoked interval is 1mS*/);



    }
}

static void front_led_k_msg_handle(mo_btn_pattern_t btn_patt, u8 click_num){

}
static void music_ducking_k_msg_handle(mo_btn_pattern_t btn_patt, u8 click_num){

}
static void outdoor_m_k_msg_handle(mo_btn_pattern_t btn_patt, u8 click_num){

}
static void voicing_m_k_msg_handle(mo_btn_pattern_t btn_patt, u8 click_num){

}
static void feedback_k_msg_handle(mo_btn_pattern_t btn_patt, u8 click_num){

}

static void btn_msg_handle(mo_vk_code_t code, mo_btn_pattern_t btn_patt, u8 click_num) {
    switch (code) {
        case HW_KEY_FRONT_LED:
            front_led_k_msg_handle(btn_patt, click_num);
            break;
        case HW_MUSIC_DUCKING:
            music_ducking_k_msg_handle(btn_patt, click_num);
            break;
        case HW_OUTDOOR_MODE:
            outdoor_m_k_msg_handle(btn_patt, click_num);
            break;
        case HW_VOICING_MODE:
            voicing_m_k_msg_handle(btn_patt, click_num);
            break;
        case HW_FEEDBACK_ELIM:
            feedback_k_msg_handle(btn_patt, click_num);
            break;

        default:
            break;
    }
}

void usr_app_init(void){
    memset(&usr_tsk,0,sizeof(usr_tsk));
    mo_btn_init(btn_msg_handle);

}
